/*
 * Powered By [rapid-framework]
 * Web Site: http://www.rapid-framework.org.cn
 * Google Code: http://code.google.com/p/rapid-framework/
 * Since 2008 - 2012
 */

package com.tech15.task.dao;

import java.util.HashMap;
import java.util.Map;

import javacommon.base.BaseHibernateDao;

import org.springframework.stereotype.Repository;

import cn.org.rapid_framework.page.Page;
import cn.org.rapid_framework.page.PageRequest;

import com.tech15.task.model.TaskSuper;
import com.tech15.task.vo.query.TaskSuperQuery;

@Repository
public class TaskSuperDao extends BaseHibernateDao<TaskSuper,java.lang.String>{

	public Class getEntityClass() {
		return TaskSuper.class;
	}
	
	public Page findByPageRequest(PageRequest<Map> pageRequest) {
		//XsqlBuilder syntax,please see http://code.google.com/p/rapid-xsqlbuilder
		// [column]为字符串拼接, {column}为使用占位符. 以下为图方便采用sql拼接,适用性能要求不高的应用,使用占位符方式可以优化性能. 
		// [column] 为PageRequest.getFilters()中的key
		String sql = "select t from TaskSuper t where 1=1 "
				+ "/~ and t.userid = '[userid]' ~/"
				+ "/~ order by [sortColumns] ~/";
		return pageQuery(sql,pageRequest);
	}
	
	public Page findPage(TaskSuperQuery query) {
		String sql = "select t.*,t1.realname from Task_Super t left join sys_user t1 on t.userid=t1.userid where 1=1 "
			  	+ "/~ and t.userid = [userid] ~/"
				+ "/~ order by [sortColumns] ~/";
		Map map = new HashMap();
		map.put("id", "String");
		map.put("userid", "Long");
		map.put("realname","String");
		return pageSqlQuery(sql, query, map, TaskSuper.class);
	}
	

}
